<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/doctrine/BaseFormFilterDoctrine.class.php');

/**
 * Contract filter form base class.
 *
 * @package    filters
 * @subpackage Contract *
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 11675 2008-09-19 15:21:38Z fabien $
 */
class BaseContractFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'project_id'         => new sfWidgetFormDoctrineChoice(array('model' => 'Project', 'add_empty' => true)),
      'category'           => new sfWidgetFormChoice(array('choices' => array('' => '', 'Materials' => 'Materials', 'Labor' => 'Labor', 'Equipment' => 'Equipment'))),
      'contractor'         => new sfWidgetFormFilterInput(),
      'date'               => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'bid_amount'         => new sfWidgetFormFilterInput(),
      'total_release'      => new sfWidgetFormFilterInput(),
      'total_disbursement' => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'project_id'         => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'Project', 'column' => 'id')),
      'category'           => new sfValidatorChoice(array('required' => false, 'choices' => array('Materials' => 'Materials', 'Labor' => 'Labor', 'Equipment' => 'Equipment'))),
      'contractor'         => new sfValidatorPass(array('required' => false)),
      'date'               => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'bid_amount'         => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'total_release'      => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'total_disbursement' => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('contract_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Contract';
  }

  public function getFields()
  {
    return array(
      'id'                 => 'Number',
      'project_id'         => 'ForeignKey',
      'category'           => 'Enum',
      'contractor'         => 'Text',
      'date'               => 'Date',
      'bid_amount'         => 'Number',
      'total_release'      => 'Number',
      'total_disbursement' => 'Number',
    );
  }
}